<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
        }
        #app{
            width: 500px;height: 600px;
            margin: 50px auto;

        }
        #tab_content{
            display: flex;


            /* flex-direction: column; */
        }
        .oul {
            display: flex;
            text-align: center;
            line-height: 46px;
            flex: 1;


            /* flex-direction: column; */
        }

        li {
            flex: 1;
            align-items: center;
            justify-content: center;
        }

        .box {
            flex: 1;
            min-width: 454px;
            text-align: center;
            line-height: 200px;
            font-size: 26px;
            background-color: blueviolet;
            color: #fff;
        }

        .active {
            background: orange;
            color: #fff;
        }
    </style>
</head>

<body>

    <div id="app">
        <my-tab :list="['语文', '数学', '英语']" :ssss="ssss"></my-tab>
        <button @click="changeStyle('vertical')">竖向展示</button>
        <button @click="changeStyle('horizontal')">横向展示</button>
    </div>




    <template id="tab">
        <div id="tab_content" :style="{'flex-direction': aaaa }">
            <ul class="oul" :style="{'flex-direction': bbbb }">
                <li v-for="(item, index) in list" :class="index === count? 'active': ''" @click="changeIndex(index)">
                    {{ item }}
                </li>
            </ul>
            <div class="box">
                {{ list[count] }}
            </div>
        </div>
    </template>



    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>

        const Tab = {
            template: "#tab",
            props: ["list","ssss"],
            data() {
                return {
                    // 当前选中的状态
                    count: 0,
                    aaaa: 'column',
                    bbbb: 'row',
                }
            },
            methods: {
                changeIndex(index) {
                    this.count = index;
                }
            },
            watch:{
                ssss(){
                    if(this.ssss==="horizontal"){
                    this.aaaa="column";
                    this.bbbb="row";
                }else if(this.ssss==="vertical"){
                    this.aaaa="row";
                    this.bbbb="column";
                }
                }
            }
        }


        new Vue({
            // 元素
            el: "#app",
            data :{
                ssss:"horizontal"
            },
            methods : {
                changeStyle(style){
                    this.ssss = style;
                }
            },
            mounted () {
                this.changeStyle("horizontal")
            },
            components: {
                "my-tab": Tab
            }
        })
    </script>
</body>

</html>